From: Philipp Hahn Date: Thu, 1 Dec 2011 18:30:29 +0000 (+0000) Subject: xend: insufficient quoting in tapdisk X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=f065c8c4aa02961b845123c3c07bc79976dfe4b5;p=xen.git xend: insufficient quoting in tapdisk insufficient quoting between "tap-ctl list" and xend/server/BlktapController.py BlktapController splits the output into lines using \n, then each line at each space, and finally each of these 'words' at the '=', which fails if the filename contains spaces. As a quick work-around, the attached patch fixes the problem for me. That is, until tap-ctl changes it's output format. A more permanent solution would be to add proper quoting / escaping to tap-ctl and un-quoting / de-escaping to BlktapController.py Signed-off-by: Philipp Hahn Committed-by: Ian Jackson --- diff --git a/tools/python/xen/xend/server/BlktapController.py b/tools/python/xen/xend/server/BlktapController.py index 7d4e5a88d5..51647e2d92 100644 --- a/tools/python/xen/xend/server/BlktapController.py +++ b/tools/python/xen/xend/server/BlktapController.py @@ -249,11 +249,12 @@ class TapdiskController(object): _list = TapdiskController.exc('list') if not _list: return [] - for line in _list.split('\n'): + for line in _list.splitlines(): tapdisk = TapdiskController.Tapdisk() - for pair in line.split(): - key, value = pair.split('=') + # Since 'tap-ctl list' does not escape blanks in the path, hard-code the current format using 4 pairs to prevent splitting the path + for pair in line.split(None, 4): + key, value = pair.split('=', 1) if key == 'pid': tapdisk.pid = value elif key == 'minor': @@ -264,7 +265,7 @@ class TapdiskController(object): elif key == 'state': tapdisk.state = value elif key == 'args' and value.find(':') != -1: - tapdisk.dtype, tapdisk.image = value.split(':') + tapdisk.dtype, tapdisk.image = value.split(':', 1) tapdisks.append(tapdisk)